package top.lgd.enums;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 账户类型
 */
@Getter
public enum AccountTypeEnum {

    finance("finance", AccountAttrEnum.A.name(), " | 余额："),
    claim("claim", AccountAttrEnum.A.name(), " | 应还余额："),
    credit("credit", AccountAttrEnum.D.name(), " | 已用金额："),
    debt("debt", AccountAttrEnum.D.name(), " | 应还金额："),
    loan("loan", AccountAttrEnum.D.name(), " | 已贷金额：");

    private String type, attr, balanceDesc;

    AccountTypeEnum(String type, String attr, String balanceDesc) {
        this.type = type;
        this.attr = attr;
        this.balanceDesc = balanceDesc;
    }

    private final static Map<String, String> attrMap = new HashMap<>();
    private final static Map<String, String> balanceDescMap = new HashMap<>();

    static {
        for (AccountTypeEnum accountTypeEnum : AccountTypeEnum.values()) {
            attrMap.put(accountTypeEnum.getType(), accountTypeEnum.getAttr());
            balanceDescMap.put(accountTypeEnum.getType(), accountTypeEnum.getBalanceDesc());
        }
    }

    public static String getAttr(String type) {
        return attrMap.get(type);
    }

    public static String getBalanceDesc(String type) {
        return balanceDescMap.get(type);
    }
}